import 'package:flutter/material.dart';
import 'package:macnov/common/indicator.dart';
import 'package:macnov/models/budget.dart';
import 'package:macnov/role_employee/budget/overview.dart';
import 'package:macnov/role_employee/budget/people.dart';

class HeaderItemBean {
  final String labelTitle;
  HeaderItemBean(this.labelTitle);
}

final List<HeaderItemBean> _allPages = <HeaderItemBean>[
  new HeaderItemBean("overview"),
  new HeaderItemBean("people"),
];

class BudgetDetail extends StatelessWidget {
  Widget _renderTabs() {
    return Material(
      color: Colors.white,
      child: new TabBar(
        isScrollable: true,
        indicator: YLStatisticsIndictor(),
        tabs: _allPages
            .map((HeaderItemBean page) => new Tab(
                    child: Text(
                  page.labelTitle,
                  style: TextStyle(
                      color: Colors.black, fontWeight: FontWeight.bold),
                )))
            .toList(),
      ),
    );
  }

  Widget _renderBody(BudgetModel budgetModel) {
    return TabBarView(children: <Widget>[
      new Overview(budgetModel: budgetModel),
      new PeopleList(),
    ]);
  }

  @override
  Widget build(BuildContext context) {
    BudgetModel budgetModel = ModalRoute.of(context).settings.arguments;

    return new DefaultTabController(
        length: _allPages.length,
        child: new Scaffold(
          appBar: new AppBar(
            title: Text('BUDGET DETAILS'),
          ),
          body: Column(
            children: <Widget>[
              Row(
                mainAxisAlignment: MainAxisAlignment.start,
                children: <Widget>[
                  Container(
                    padding: EdgeInsets.only(top: 20, bottom: 20, left: 10),
                    child: Text(
                      budgetModel.name,
                      style:
                          TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
                    ),
                  )
                ],
              ),
              Container(
                color: Colors.white,
                child: _renderTabs(),
                height: 30,
                width: MediaQuery.of(context).size.width,
              ),
              Expanded(
                child: _renderBody(budgetModel),
              )
            ],
          ),
        ));
  }
}
